#include "AttributesDialog.hpp"
#include "ui_AttributesDialog.h"

AttributesDialog::AttributesDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::AttributesDialog)
{
    ui->setupUi(this);
    setWindowTitle("Attributes");
}

AttributesDialog::~AttributesDialog()
{
    delete ui;
}

void AttributesDialog::setNodeInfo(const Node* const node)
{
    ui->newName->setPlainText(node->getName().c_str());
    switch(node->getType())
    {
        case Node::ABSTRACT :
            ui->nodeTypeBox->setCurrentIndex(0);
            break;
        case Node::USER :
            ui->nodeTypeBox->setCurrentIndex(1);
            break;
        case Node::APPLICATION :
            ui->nodeTypeBox->setCurrentIndex(2);
            break;
        case Node::INTERACTION :
            ui->nodeTypeBox->setCurrentIndex(3);
            break;
        default :
            break;
    }
}


QString AttributesDialog::getName()
{
    return ui->newName->toPlainText();
}

Node::NodeType AttributesDialog::getType()
{
    switch(ui->nodeTypeBox->currentIndex())
    {
        case 0 : return Node::ABSTRACT;
        case 1 : return Node::USER;
        case 2 : return Node::APPLICATION;
        case 3 : return Node::INTERACTION;
        default : return Node::ABSTRACT;
    }
}
